// pages/customizeActivity/myCustomize/myCustomize.js
var util = require('../../../utils/util.js');
var wxcache = require('../../../utils/wxcache.js');
var api = require('../../../config/api.js');
var user = require('../../../services/user.js');

var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    customizeLists:null,



  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

    var that = this;
    var data={}
    data.pageNo = 1
    data.pageSize = 500 //后面换成分页
    util.request(api.listEnterpriseCustomization, data).then(res=>{

        if(res.code == 200){
          console.log(res)
          var process =res.responseBody.enterpriseCustomizationRespList
          // if (process){
          //   for (var index = 0; index < process.length;index++){
          //     var gap = that.dateMinus(process[index].campaignBeginStart, process[index].campaignBeginEnd)
          //     process[index].gap =  gap
          //   }
            

          // }
          that.setData({
            customizeLists: process
          })
         
        }
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },
  switchTab: function (e) {
    wx.redirectTo({
      url: '/pages/customizeActivity/companyCustomize/companyCustomize',
    })
  },
  toDetails:function(e){
    console.log(e)
    wx.navigateTo({
      url: '/pages/customizeActivity/myCustomize/customizeDetails/customizeDetails?id=' + e.currentTarget.dataset.itemid ,
    })
  },
  dateMinus: function (sDate, eDate) {
    if (!sDate || !eDate) {
      return null;
    }
    var sdate = new Date(sDate.replace(/\./g, "/"));
    var eDate = new Date(eDate.replace(/\./g, "/"));
    var days = eDate.getTime() - sdate.getTime();
    var day = parseInt(days / (1000 * 60 * 60 * 24));
    return day + 1;
  },
})
